package com.s666.demo.service.impl;

import com.s666.demo.service.KafkaService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author lijin
 */
@Service
@Slf4j
public class KafkaServiceImpl implements KafkaService {

    private static final String TOPIC_NAME = "test";

    @Resource
    private KafkaTemplate<String, String> kafkaTemplate;


    @Override
    public void product(String topic, Integer num) {
        kafkaTemplate.send(TOPIC_NAME, num.toString());
    }

    @Override
//    @KafkaListener(topics = {TOPIC_NAME}) //@todo 这里打开即接受kafka消息
    public void customer(Integer record) {
        System.err.println("---------test----------" + record);
//        System.out.println("topic" + record.topic());
//        System.out.println("key:" + record.key());
//        System.out.println("value:"+record.value());
    }

}
